Skip to content

feat: add depth option to clone/fetch for shallow clones#30

Merged
mizchi merged 1 commit into
mainfrom
feat/clone-depth
May 29, 2026
Merged

feat: add depth option to clone/fetch for shallow clones#30
mizchi merged 1 commit into
mainfrom
feat/clone-depth

Conversation

@mizchi
Copy link
Copy Markdown
Member

@mizchi mizchi commented Mar 31, 2026

Summary

  • Expose existing protocol-level deepen support to the JavaScript API
  • Add depth?: number to BitCloneOptions and BitFetchOptions
  • When depth is 0 (default), full clone behavior is preserved
  • When depth > 0, the server returns only the specified number of commits

Changes

  • src/lib/js_api_exports.mbt: Add depth : Int parameter to js_clone_remote, js_fetch_remote, and their promise wrappers
  • npm/lib.js: Pass options.depth ?? 0 to raw clone/fetch calls
  • npm/lib.d.ts: Add depth?: number to option interfaces

Usage

import { clone, createFetchTransport } from "@mizchi/bit";

// Full clone (default, depth=0)
await clone(backend, "/repo", url, transport);

// Shallow clone (depth=1)
await clone(backend, "/repo", url, transport, { depth: 1 });

Test plan

  • Full clone still works (depth=0, default)
  • Shallow clone with depth=1 returns single commit
  • Fetch with depth works similarly

🤖 Generated with Claude Code

Expose the existing protocol-level deepen support to the JavaScript API.
The depth parameter is passed through to fetch_pack_with_http which
encodes it as "deepen {depth}" in the git smart HTTP protocol.

When depth is 0 (default), full clone behavior is preserved.
When depth > 0, the server returns only the specified number of commits.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mizchi mizchi force-pushed the feat/clone-depth branch from 0074fd1 to 0be2458 Compare May 29, 2026 12:30
@mizchi mizchi merged commit 1d5a9a1 into main May 29, 2026
mizchi pushed a commit that referenced this pull request May 29, 2026
- bit_repo_ops/moon.mod.json: add mizchi/bit_utils dep (required by
  moon workspace resolver - all transitive deps must be declared)
- js_exports_wbtest.mbt: pass depth=0 to js_clone_remote (PR #30 added
  depth param, test wasn't updated)
@mizchi mizchi deleted the feat/clone-depth branch May 29, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant